---
redirect_from:
  - /cloud/dev-tools/dev-playground
  - /dev-tools/dev-playground
---

# Playground

Playground is a web-based tool which allows executing queries and previewing
their results.

<SuccessBox>

Playground is available in Cube Cloud on [all tiers](https://cube.dev/pricing).

</SuccessBox>

Cube Core and Cube Cloud both provide the Playground experience; however, a few
additional features are available in Cube Cloud.

<Screenshot
  alt="Playground Query and Results Example"
  src="https://ucarecdn.com/06bece10-f322-4b4a-9250-234d1bae98db/"
/>

## Running Playground

### Cube Core

Playground is available at [http://localhost:4000](http://localhost:4000) when
Cube is run in [development mode][ref-dev-mode], i.e., when `CUBEJS_DEV_MODE` is
set to `true`.

<WarningBox>

Since Playground exposes all data models and allows running all possible
queries, it should not be used in production. You can [connect a BI
tool][ref-dataviz-tools] or use the [JavaScript SDKs][ref-js-sdk] to build your
own query builder and use it to query your Cube in a secure way.

</WarningBox>

You can use this Playground to view and [generate data model][ref-data-model]
files.

<WarningBox>

Data model generator currently has the following limitations:
- Even if [multiple data sources][ref-multiple-data-sources] are configured,
it will only show the tables from in default data source. As a workaround, you
can configure the second data source as default, generate data model files for
it, then change the default data source back.
- With each generation, files in the data model folder will be rewritten. If
you'd like to combine files from multiple generations, please back them up
manually. 

</WarningBox>

### Cube Cloud

Playground is available out of the box to authenticated [Cube Cloud][cube-cloud]
users.

When editing the data model through the [data model editor][ref-devtools-ide],
Playground will switch to the Development API and its status will be visible in
Playground:

<Screenshot
  alt="Playground during API restart"
  src="https://ucarecdn.com/06bece10-f322-4b4a-9250-234d1bae98db/"
/>

## Query tabs

You can use query tabs to keep results of previous queries while still being
able to make new queries. The query tabs can be found at the top of the
Developer Playground:

<Screenshot
  alt="Cube Developer Playground Tabs"
  src="https://ucarecdn.com/06bece10-f322-4b4a-9250-234d1bae98db/"
/>

You can also double-click a query tab to give it a meaningful name:

<video width="100%" controls>
  <source
    src="https://ucarecdn.com/9e3d7651-4dca-4cd3-9fc9-541c3182effd/video.mp4"
    type="video/mp4"
  />
</video>

## Editing the Security Context

The security context used for queries can be modified by clicking <Btn>Add
Security Context</Btn>:

<Screenshot src="https://ucarecdn.com/06bece10-f322-4b4a-9250-234d1bae98db/" />

You can paste in an existing JWT if desired; or create a brand-new one by
providing a JSON object that represents the decoded JWT.

## Executing generated SQL

To see the SQL generated by a query, click <Btn>Generated SQL</Btn>:

<Screenshot src="https://ucarecdn.com/43011e86-8a0e-414b-a192-3c07a47c2694/" />

If you're using Cube Cloud, you can copy this SQL and run it in your data source
using the [SQL Runner][ref-workspace-sqlrunner].

## Accelerating queries

When you execute a query that has no matching [pre-aggregations][ref-caching-preaggs-gs],
you would see this notificaton. Clicking on it will open [Rollup
Designer][ref-rollup-designer] that would help you create a pre-aggregation
to accelerate the query:

<Screenshot
  highlight="inset(22.5% 0 65% 72.5% round 10px)"
  src="https://ucarecdn.com/582acb98-373b-4617-9aa8-263b0653cd00/"
/>

[cube-cloud]: https://cube.dev/cloud
[ref-dev-mode]: /product/configuration
[ref-devtools-ide]: /cloud/dev-tools/cube-ide
[ref-caching-preaggs-gs]: /product/caching/getting-started-pre-aggregations
[ref-workspace-sqlrunner]: /product/workspace/sql-runner
[ref-rollup-designer]: /product/workspace/rollup-designer
[ref-dataviz-tools]: /product/configuration/visualization-tools
[ref-js-sdk]: /product/apis-integrations/javascript-sdk
[ref-data-model]: /product/workspace/data-model#generating-data-model-files
[ref-multiple-data-sources]: /product/configuration/advanced/multiple-data-sources